<!DOCTYPE html>
<html lang="en">
<head>
    <title>监测设备列表</title>
    {% include 'admin/common/header.html' %}
</head>
<body class="pear-container">
{# 查询表单 #}
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="" lay-filter="user-query-form">
            <div class="layui-form-item">
                <label class="layui-form-label">设备名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="equip_name" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">设备型号</label>
                <div class="layui-input-inline">
                    <input type="text" name="equip_type" placeholder="" class="layui-input">
                </div>
                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="equip-info-query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
</div>
{# 用户表格 #}
<div class="user-main user-collasped">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="equip-list-table" lay-filter="equip-list-table"></table>
        </div>
    </div>
</div>
</body>

<script type="text/html" id="dict-type-toolbar">
{#    {% if authorize("admin:user:add") %}#}
        <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
            <i class="pear-icon pear-icon-add"></i>
{#            新增#}
        </button>
{#    {% endif %}#}
{#    {% if authorize("admin:user:remove") %}#}
{#        <button class="pear-btn pear-btn-md" lay-event="batchRemove">#}
{#            <i class="pear-icon pear-icon-ashbin"></i>#}
{#            删除#}
{#        </button>#}
{#    {% endif %}#}
</script>

{# 设备修改操作#}
<script type="text/html" id="dict-opt-bar">
{#         查看详情图标#}
        <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="details"><i
                class="pear-icon pear-icon-file"></i>
        </button>
</script>
{% include 'admin/common/footer.html' %}
<script>
  layui.use(['table', 'dtree', 'form', 'jquery', 'popup', 'common'], function () {
    let table = layui.table
    let form = layui.form
    let $ = layui.jquery
    {#let dtree = layui.dtree#}
    {#let popup = layui.popup#}
    {#let common = layui.common#}

    let cols = [
      [
        { title: '设备名称', field: 'equip_name', align: 'center' },
        { title: '设备型号', field: 'equip_type', align: 'center' },
        { title: '设备状态', field: 'equip_state', align: 'center' },
          {title: '信息更新时间',field: 'create_time', templet:'#user-createTime',align: 'center'},
        { title: '查看详情', toolbar: '#dict-opt-bar', align: 'center', width: 240 }
      ]
    ]

table.render({
      elem: '#equip-list-table',
      url: '/admin/monitor/list/data',
      page: true,
      cols: cols,
      skin: 'line',
      height: 'full-148',
      toolbar: '#dict-type-toolbar',
      text: { none: '暂无设备列表' },
      defaultToolbar: [{
        layEvent: 'refresh',
        icon: 'layui-icon-refresh',
      }, 'filter', 'print', 'exports']
    })


    window.refreshType = function () {
      table.reload('equip-list-table')
    }

    table.on('tool(equip-list-table)', function (obj) {

       if (obj.event === 'details') {
        window.detailsType(obj)
      }
    })
      window.detailsType = function (obj) {
      layer.open({
        type: 2,
        title: '防火器',
        shade: 0.1,
        area: ['100%', '100%'],
        content: '/admin/monitor/list/details'
      })
    }
    table.on('toolbar(equip-list-table)', function (obj) {
      if (obj.event === 'refresh') {
        window.refreshData()
      }else if(obj.event == 'add'){
          window.addNewEquip()
      }
    })

     form.on('submit(equip-info-query)', function (data) {
      table.reload('equip-list-table', { where: data.field })
      return false
    })

    {# 增加新设备#}
    window.addNewEquip = function () {
     layer.open({
        type: 2,
        title: '新增',
        shade: 0.1,
        area: ['550px', '550px'],
        content: '/admin/monitor/list/adds'
      })
    }
    window.refreshData = function () {
      table.reload('equip-list-table')
    }
  })
</script>

</html>